
from unittest import TestCase
from ddt  import ddt,data,unpack
from selenium import webdriver
from RegisterOperation import RegisterOperation
from Register_data import Register_data

@ddt
class Test2Register(TestCase):

    @data(*Register_data.register_success_data)
    @unpack
    def testRegister1(self,username,password1,password2,expect,case):

        #  开始测试
        driver = webdriver.Chrome()

        driver.get("http://localhost:90")
        driver.maximize_window()

        reg = RegisterOperation()
        reg.register(driver,username,password1,password2)

        result = reg.getResult(driver)

        if result != expect:
            driver.save_screenshot(f'D:/Users/北极星的眼泪/Desktop/demo/自动化测试第三四天/报错截图/{case}.png')
        else:
            print("通过")

        driver.quit()

        self.assertEqual(expect,result)


    @data(*Register_data.register_Error_data)
    @unpack
    def testRegister2(self, username, password1, password2, expect, case):

        #  开始测试
        driver = webdriver.Chrome()

        driver.get("http://localhost:90")
        driver.maximize_window()

        reg = RegisterOperation()
        reg.register(driver, username, password1, password2)

        result = reg.getResult(driver)

        if result != expect:
            driver.save_screenshot(f'D:/Users/北极星的眼泪/Desktop/demo/自动化测试第三四天/报错截图/{case}.png')
        else:
            print("通过")

        driver.quit()

        self.assertEqual(expect, result)